﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register TagPrefix="dotnet" Namespace="dotnetCHARTING" Assembly="dotnetCHARTING"%>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<%@ Import Namespace="C3.Proto.Core.Model"%>
<%@ Import Namespace="C3.Proto.Core.Service"%>
<%@ Import Namespace="C3.Proto.Repo"%>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Home Page
</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
<% var last = (string)ViewData["LastRunDate"]; %>
<% if(!string.IsNullOrEmpty(last))
   { %>
  <h3>Last Import: <%=last %></h3>    
<%   } %>
<form method="get" id="reportform" action="Home/AllProjectsExport">
<p>

    <select name="type" id="type" style="width: 460px" onchange="ShowType(); return false;">

    
        <%--CHANGES HAVE BEEN SUCCESSFULLY COMMITTED --%>
       
	<option value="all">All Project Analysis Export</option>
	<option value="project">Project Analysis Export</option>
	<option value="state">Statewide Summary Report</option>
        
	<option value="region">Region Summary Report</option>
        
    
    </select>


    <select id="region" name="region" style="width: 460px;display:none" class="filter">    
        <option value="1. Austin">Austin</option>
        <option value="2. North Texas">North TX</option>
        <option value="3. West Texas">West TX</option>
        <option value="4. South Texas">South TX</option>
        <option value="6. Galveston">Galveston</option>
        <option value="8. SWMC">UTSWMC</option>
        <option value="7. MDACC">MDA</option>
    </select>
    

    <% var p = (IList<Project>) ViewData["Projects"];%>
    <select id="project" name="project" style="width: 460px;display:none" class="filter"> 
         
    <%if (p.Count > 0)
      {
          foreach (var proj in p)
          {
              if (proj.Description != null)
              {%>          
       <option value="<%=proj.Name%>"><%=proj.Name%>&nbsp;&nbsp;<%=proj.Description%></option> 
      <% }
              else
              {%>
       <option value="<%=proj.Name%>"><%=proj.Name%></option>     
   <%   }
          }
      }
      else
      {%>
       <option value="null">No Projects Loaded!</option>
      <%} %>

    </select>
<br />

    <select  id="startmonth" name="startmonth"  style="width: 80px"> 
        <option value="01">01</option>
        <option value="02">02</option>
        <option value="03">03</option>
        <option value="04">04</option>
        <option value="05">05</option>
        <option value="06">06</option>
        <option value="07">07</option>
        <option value="08">08</option>
        <option value="09">09</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
    </select>



    <select  id="startyear" name="startyear" style="width: 80px" > 
        <option value="2013">2013</option>
        <option value="2012">2012</option>
        <option value="2011">2011</option>
        <option value="2010">2010</option>
        <option value="2009">2009</option>
        <option value="2008">2008</option>
    </select>



    <b>to</b>



    <select id="endmonth" name="endmonth" style="width: 80px"> 
        <option value="01">01</option>
        <option value="02">02</option>
        <option value="03">03</option>
        <option value="04">04</option>
        <option value="05">05</option>
        <option value="06">06</option>
        <option value="07">07</option>
        <option value="08">08</option>
        <option value="09">09</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
    </select>

    <select id="endyear" name="endyear" style="width: 80px;"> 
        <option value="2013">2013</option>
        <option value="2012">2012</option>
        <option value="2011">2011</option>
        <option value="2010">2010</option>
        <option value="2009">2009</option>
        <option value="2008">2008</option>
    </select>

    <br />
        <input value="Submit" type="submit" id="info-submit" name="submit" /><input type="button" onclick="Reset();return false;" value="Reset">
    
</p>
<%--   <% var history = (IList<JobHistory>)ViewData["History"]; %>
   <% if(history != null){
        foreach (var h in history){%>
            <%=h.Name %>-<%=h.Date %>-<%=h.Duration %><br/>
        <%} %>
   <%} %>--%>

<%if (ViewData["User"] == null){ %>
<a href="/Login/">Log in</a>
<%} else { %>
</form>
<form action="/Home/AddCSV/" method="post" enctype="multipart/form-data">
<input type="hidden" name="id" value="<%=((User)ViewData["User"]).Id %>" />
Upload: <input type="file" name="doc" />
<select id="type" name="doctype">
    <option value="RIR">RIR</option>
    <option value="STEP">Steps</option>
    <option value="claims">Claims</option>
    <option value="Manhours">Manhours</option>
</select> 
&nbsp;&nbsp;<input type="submit" value="Save" class="button" />
</form>
<a class="button-link" href="/Login/Out" title="Logout" rel="tooltip">logout</a></li>
<%} %>

<script type="text/javascript">

    $('#endmonth option').eq(new Date().getMonth() - 1).attr('selected', 'selected');
    $('#startyear').val(new Date().getFullYear());
    $('#endyear').val(new Date().getFullYear());

    function ShowType() {
        $(".filter").hide();
        if ($("#type").val() == "project") {
            $("#dates").show();
            $("#project").show();
            $("#reportform").attr("action", "Home/ProjectExport");


        } else if ($("#type").val() == "region") {
            $("#region").show();
            $("#reportform").attr("action", "Home/RegionExport");
        }
        else if ($("#type").val() == "all") {
           
            $("#reportform").attr("action", "Home/AllProjectsExport");
        }   
         else {
            $("#reportform").attr("action", "Home/StateExport");
        }

    }

  function Reset(){
        $('#endmonth option').eq(new Date().getMonth() - 1).attr('selected', 'selected');
        $('#startyear').val(new Date().getFullYear());
        $('#endyear').val(new Date().getFullYear());

        $("#reportform").attr("action", "Home/StateExport");
        $(".filter").hide();
        $("#type").val("state");
}
</script>
</asp:Content>